package com.qding.park.manager.service.core.facade.impl.common;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import com.qding.park.common.core.constant.MongodbConstant;
import com.qding.park.common.core.exceptions.BaseException;
import com.qding.park.common.utils.string.StringUtil;
import com.qding.park.manager.cache.ParkCacheInter;
import com.qding.park.manager.facade.core.service.common.TerminalStatisFacade;
import com.qding.park.manager.pojo.TbParkspace;
import com.qding.park.manager.pojo.TerminalClickInfo;
import com.qding.park.manager.service.core.mapper.TbProjectMapper;

@Service("terminalStatisFacade")
public class TerminalStatisFacadeImpl implements TerminalStatisFacade {
	
	private static final Log _log = LogFactory.getLog(TerminalStatisFacadeImpl.class);
	
	@Autowired
	private MongoTemplate mongoTemplate;
	
	
	@Autowired
	private TbProjectMapper  tbProjectMapper;
	
	@Autowired
	private ParkCacheInter  parkCacheInter;

	@Override
	public void terminalClick(TerminalClickInfo clickInfo) throws BaseException {
		
		String projectId=clickInfo.getProjectId();
		if(!StringUtils.isBlank(clickInfo.getParkId())){
			TbParkspace tbParkspace=parkCacheInter.queryParkSpace(Integer.valueOf(clickInfo.getParkId()));
			clickInfo.setParkName(tbParkspace==null?null:tbParkspace.getName());
		}
		if(StringUtil.isBlank(clickInfo.getParkId())){
			clickInfo.setParkId("");
		}
		String terminal_tablename = MongodbConstant.TABLENAME_TERMINALLOG;
		mongoTemplate.insert(clickInfo, terminal_tablename);
	}

}
